package redis

import (
	"context"
	"fmt"
	"github.com/go-redis/redis/v8"
	"online-medical-consultation/common/nacos"
	"time"
)

var Rdb *redis.Client

func InitRedis() {
	nac := nacos.NacosConfig.Redis
	Rdb = redis.NewClient(&redis.Options{
		Addr:     nac.Addr,
		Password: nac.Password, // no password set
		DB:       nac.Db,       // use default DB
	})
	fmt.Println("redis连接成功")

}
func SetSms(key string, code int) {
	Rdb.Set(context.Background(), key, code, time.Minute*10)
}
func GetSms(key string) int {
	get, _ := Rdb.Get(context.Background(), key).Int()
	return get
}
func DelSms(key string) {
	Rdb.Del(context.Background(), key)
}
